package com.ruoyi.project.platform.service.impl;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
import com.ruoyi.framework.security.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.platform.mapper.PltUserPlatformMapper;
import com.ruoyi.project.platform.domain.PltUserPlatform;
import com.ruoyi.project.platform.service.IPltUserPlatformService;

/**
 * 用户和交易所关联Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-07-27
 */
@Service
public class PltUserPlatformServiceImpl implements IPltUserPlatformService 
{
    @Autowired
    private PltUserPlatformMapper pltUserPlatformMapper;

    /**
     * 查询用户和交易所关联
     * 
     * @param platform 用户和交易所关联ID
     * @return 用户和交易所关联
     */
    @Override
    public PltUserPlatform selectPltUserPlatformById(String platform)
    {
        return pltUserPlatformMapper.selectPltUserPlatformById(platform);
    }

    /**
     * 查询用户和交易所关联列表
     * 
     * @param pltUserPlatform 用户和交易所关联
     * @return 用户和交易所关联
     */
    @Override
    @DataScope(userAlias = "u")
    public List<PltUserPlatform> selectPltUserPlatformList(PltUserPlatform pltUserPlatform)
    {
        return pltUserPlatformMapper.selectPltUserPlatformList(pltUserPlatform);
    }

    /**
     * 新增用户和交易所关联
     * 
     * @param pltUserPlatform 用户和交易所关联
     * @return 结果
     */
    @Override
    public int insertPltUserPlatform(PltUserPlatform pltUserPlatform)
    {
        LoginUser currentUser = SecurityUtils.getLoginUser();
        pltUserPlatform.setUserId(currentUser.getUser().getUserId());
        pltUserPlatform.setUserName(currentUser.getUser().getUserName());
        return pltUserPlatformMapper.insertPltUserPlatform(pltUserPlatform);
    }

    /**
     * 修改用户和交易所关联
     * 
     * @param pltUserPlatform 用户和交易所关联
     * @return 结果
     */
    @Override
    public int updatePltUserPlatform(PltUserPlatform pltUserPlatform)
    {
        return pltUserPlatformMapper.updatePltUserPlatform(pltUserPlatform);
    }

    /**
     * 批量删除用户和交易所关联
     * 
     * @param platforms 需要删除的用户和交易所关联ID
     * @return 结果
     */
    @Override
    public int deletePltUserPlatformByIds(String[] platforms)
    {
        return pltUserPlatformMapper.deletePltUserPlatformByIds(platforms);
    }

    /**
     * 删除用户和交易所关联信息
     * 
     * @param platform 用户和交易所关联ID
     * @return 结果
     */
    @Override
    public int deletePltUserPlatformById(String platform)
    {
        return pltUserPlatformMapper.deletePltUserPlatformById(platform);
    }
}
